using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace SPTraceView.Model
{
    /// <summary>
    /// For more info see http://msdn.microsoft.com/hi-in/library/aa979595(en-us).aspx
    /// </summary>
    internal static class ULS
    {
        public static string WSS_TRACE_SESSION_NAME = "WSSTRACESESSION";

        public static Guid WSSProviderGuid
        {
            get
            {
                // Taken from Microsoft.SharePoint.Administration.SPFarm.TraceSessionGuid
                // To avoid referencing any SharePoint DLLs
                return new Guid(0x89c8c935, 0x99ff, 0x48ce, 0x93, 0x76, 0x31, 0xda, 170, 0xf3, 0x2b, 0x85);
            }
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
        internal struct ULSTraceHeader
        {
            internal ushort Size;

            internal uint Version;

            internal uint Id;

            internal Guid CorrelationID;

            internal TraceFlags Flags;

            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
            internal string ExeName;

            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
            internal string Product;

            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
            internal string Category;

            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 800)]
            internal string Message;

        }

        internal enum TraceFlags
        {
            TRACE_FLAG_START = 1,
            TRACE_FLAG_END = 2,
            TRACE_FLAG_MIDDLE = 3,
            TRACE_FLAG_ID_AS_ASCII = 4,
            TRACE_FLAG_UNKNOWN_5 = 5,
            TRACE_FLAG_UNKNOWN_6 = 6
        }

        public enum TraceSeverity
        {
            Assert = 7,
            CriticalEvent = 1,
            Exception = 4,
            High = 20,
            InformationEvent = 3,
            Medium = 50,
            Monitorable = 15,
            Unassigned = 0,
            Unexpected = 10,
            Verbose = 100,
            WarningEvent = 2
        }
    }
}
